<?php

namespace App\Models;

use App\Models\Contract\SerializeDatetime;
use Dcat\Admin\Models\Administrator;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UserWithdraw extends Model
{
    use HasFactory, SerializeDatetime;

    protected $fillable = [
        'user_id', 'wid', 'wallet_type', 'money', 'exchange_rate', 'amount',
        'before_coins', 'after_coins', 'status', 'operator_id', 'applied_at',
        'audited_at', 'remark',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function operator()
    {
        return $this->belongsTo(Administrator::class, 'operator_id');
    }
    public function parent()
    {
        return $this->hasOne(User::class, 'id','parent_id');
    }
    public function member()
    {
        return $this->hasOne(GroupMember::class, 'user_id', 'user_id');
    }

    public function transaction()
    {
        return $this->hasOne(Transaction::class);
    }
}
